<template>
	<view class="photo-move">
		<view class="empty" v-if="list.length <= 0">
			<img src="@/static/images/empty_data.png" alt="" class="empty-data">
		</view>
		<view class="" v-for="(item,index) in list" :key="index" v-else>
			<album-card :detail="item" :size="'small'" :desc-show = "false">
				<button class="see" @click="confirm(item)">选择</button>
			</album-card>
		</view>
	</view>
	
</template>

<script>
	import http from '@/pages/request/index'
	import albumCard from './components/album-card.vue';
	export default {
		components: {
			albumCard
		},
		data() {
			return {
				list:[],
				ids:[],
				albumId:''
			};
		},
		onLoad(e) {
			console.log(e.ids);
			this.ids = e.ids.split(',');
			this.albumId = e.albumId
			this.albumCatalog()
		},
		methods: {
			albumCatalog(){
				http('album.catalog',{}).then(res=>{
					console.log(res);
					this.list = res.data
				})
			},
			confirm(item){
				if(this.albumId == item.id){
					this.$u.toast('目的相册不能与源相册相同')
					return
				}
				let ids = this.ids.map((id,index)=>{
					return {id:id,weigh:index+1}
				})
				http('album.movePhoto',{images:ids,catalog_id:item.id}).then(res=>{
					console.log(res);
					this.delShow = false
					uni.setStorageSync("album_refresh", true)
					uni.showToast({
						title: '移动成功',
						duration: 2000,
						// image: require('@/static/images/icon_success.png')
					});
					uni.navigateBack()
				})
				
			}
		}
	};
</script>

<style lang="scss" scoped>
	.empty {
		display: flex;
		justify-content: center;
		.empty-data {
			width: 480rpx;
			height: 480rpx;
			margin-top: 90rpx;
		}
	}
	.photo-move {
		padding: 20rpx 24rpx;
	}
	.see {
		float: right;
		width: 160rpx;
		height: 64rpx;
		background: #00C3C5;
		border-radius: 108rpx 108rpx 108rpx 108rpx;
		border: 1rpx solid #00C3C5;
		display: flex;
		justify-content: center;
		align-items: center;
		color: #FFFFFF;
		font-size: 28rpx;
		font-weight: 500;
	}
</style>